<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.0.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto Serif SC:300,300italic,400,400italic,700,700italic|Roboto Mono:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-bounce.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"zhiruozzy.cn","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"default"},"back2top":{"enable":"truw","sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="网易云音乐的轮播图自制~">
<meta property="og:type" content="article">
<meta property="og:title" content="轮播图">
<meta property="og:url" content="http://zhiruozzy.cn/2022/04/03/%E8%BD%AE%E6%92%AD%E5%9B%BE/index.html">
<meta property="og:site_name" content="芷若">
<meta property="og:description" content="网易云音乐的轮播图自制~">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-04-03T00:09:47.000Z">
<meta property="article:modified_time" content="2022-04-05T04:08:35.885Z">
<meta property="article:author" content="芷若">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://zhiruozzy.cn/2022/04/03/%E8%BD%AE%E6%92%AD%E5%9B%BE/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>轮播图 | 芷若</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css">
<!-- hexo injector head_end end --><link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css">
<link rel="stylesheet" href="/css/prism-line-numbers.css" type="text/css"></head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">芷若</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-主页">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>主页</a>

  </li>
        <li class="menu-item menu-item-关于">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-标签">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-目录">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>目录</a>

  </li>
        <li class="menu-item menu-item-归档">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container"></div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="algolia-results">
  <div id="algolia-stats"></div>
  <div id="algolia-hits"></div>
  <div id="algolia-pagination" class="algolia-pagination"></div>
</div>

      
    </div>
  </div>

</div>
    </header>

    
  <div class="reading-progress-bar"></div>

  <a href="https://github.com/zhiruozzy" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://zhiruozzy.cn/2022/04/03/%E8%BD%AE%E6%92%AD%E5%9B%BE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/touxiang.jpg">
      <meta itemprop="name" content="芷若">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="芷若">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          轮播图
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-04-03 08:09:47" itemprop="dateCreated datePublished" datetime="2022-04-03T08:09:47+08:00">2022-04-03</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-04-05 12:08:35" itemprop="dateModified" datetime="2022-04-05T12:08:35+08:00">2022-04-05</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>6.4k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>6 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="网易云音乐的轮播图自制"><a href="#网易云音乐的轮播图自制" class="headerlink" title="网易云音乐的轮播图自制~"></a>网易云音乐的轮播图自制~</h2><span id="more"></span>

<h2 id="页面布局（HTML）"><a href="#页面布局（HTML）" class="headerlink" title="页面布局（HTML）"></a>页面布局（HTML）</h2><p><strong>首先需要一个大的div将所有元素装在里</strong></p>
<p><strong>左右按钮</strong></p>
<p>用a标签包裹</p>
<p><strong>轮播图片</strong></p>
<p>用ul包含n个li构成</p>
<p><strong>小圆圈</strong>(nav)</p>
<p>用ol包含n个li构成</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">&quot;ad&quot;</span>&gt;</span></span><br><span class="line">        <span class="comment">&lt;!-- 左右按钮 --&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span> <span class="attr">class</span>=<span class="string">&quot;left&quot;</span>&gt;</span>&gt;<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span> <span class="attr">class</span>=<span class="string">&quot;right&quot;</span>&gt;</span>&gt;<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">ul</span> <span class="attr">class</span>=<span class="string">&quot;pic&quot;</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;1.jpg&quot;</span> <span class="attr">alt</span>=<span class="string">&quot;&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;2.jpg&quot;</span> <span class="attr">alt</span>=<span class="string">&quot;&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;3.jpg&quot;</span> <span class="attr">alt</span>=<span class="string">&quot;&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span>&gt;</span><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;4.jpg&quot;</span> <span class="attr">alt</span>=<span class="string">&quot;&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">a</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">ol</span> <span class="attr">class</span>=<span class="string">&quot;nav&quot;</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span> <span class="attr">class</span>=<span class="string">&quot;selected&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span><span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">ol</span>&gt;</span></span><br><span class="line">       </span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h2 id="样式-CSS"><a href="#样式-CSS" class="headerlink" title="样式(CSS)"></a>样式(CSS)</h2><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br></pre></td><td class="code"><pre><span class="line">&lt;style&gt;</span><br><span class="line">      *&#123;</span><br><span class="line">          <span class="attribute">margin</span>:<span class="number">0px</span>;</span><br><span class="line">          <span class="attribute">padding</span>:<span class="number">0px</span>;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="selector-class">.ad</span>&#123;</span><br><span class="line">          <span class="attribute">position</span>: relative;</span><br><span class="line">          <span class="attribute">height</span>: <span class="number">420px</span>;</span><br><span class="line">          <span class="attribute">width</span>: <span class="number">1090px</span>;</span><br><span class="line">          <span class="attribute">background-color</span>: pink;</span><br><span class="line">          <span class="comment">/* 相对定位可以通过margin: xx auto来水平居中 */</span></span><br><span class="line">          <span class="attribute">margin</span>: <span class="number">50px</span> auto;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="selector-class">.left</span>,<span class="selector-class">.right</span>&#123;</span><br><span class="line">          <span class="comment">/* 因为左右箭头不能挤占照片的位置，所以应该为绝对定位（脱标） */</span></span><br><span class="line">          <span class="attribute">position</span>:absolute;</span><br><span class="line">          <span class="attribute">text-decoration</span>: none;</span><br><span class="line">          <span class="attribute">width</span>: <span class="number">20px</span>;</span><br><span class="line">          <span class="attribute">height</span>: <span class="number">30px</span>;</span><br><span class="line">          <span class="attribute">background-color</span>: <span class="built_in">rgba</span>(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0.5</span>);</span><br><span class="line">          <span class="comment">/* 绝对定位的盒子的水平居中 */</span></span><br><span class="line">          <span class="attribute">top</span>:<span class="number">50%</span>;</span><br><span class="line">          <span class="attribute">margin-top</span>: -<span class="number">10px</span>;</span><br><span class="line">          <span class="comment">/* 让里面的符号水平居中垂直居中于小盒子中 */</span></span><br><span class="line">           <span class="attribute">text-align</span>: center;</span><br><span class="line">           <span class="attribute">line-height</span>: <span class="number">30px</span>;</span><br><span class="line">           <span class="attribute">color</span>: <span class="number">#fff</span>;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="selector-class">.left</span>&#123;</span><br><span class="line">          <span class="comment">/* 设置圆角 */</span></span><br><span class="line">           <span class="attribute">border-radius</span>: <span class="number">0</span> <span class="number">15px</span> <span class="number">15px</span> <span class="number">0</span>;</span><br><span class="line">           <span class="comment">/* 靠左 */</span></span><br><span class="line">           <span class="attribute">left</span>:<span class="number">0</span>;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="selector-class">.right</span>&#123;</span><br><span class="line">          <span class="comment">/* 设置圆角 */</span></span><br><span class="line">          <span class="attribute">border-radius</span>: <span class="number">15px</span> <span class="number">0</span> <span class="number">0</span> <span class="number">15px</span>;</span><br><span class="line">          <span class="comment">/* 靠右 */</span></span><br><span class="line">          <span class="attribute">left</span>:<span class="number">1070px</span>;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="selector-tag">ul</span>,<span class="selector-tag">ol</span>&#123;</span><br><span class="line">         <span class="attribute">list-style-type</span>: none;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="selector-class">.nav</span>&#123;</span><br><span class="line">          <span class="comment">/* 绝对定位*/</span></span><br><span class="line">          <span class="attribute">position</span>: absolute;</span><br><span class="line">          <span class="attribute">bottom</span>:<span class="number">15px</span>;</span><br><span class="line">          <span class="attribute">height</span>: <span class="number">14px</span>;</span><br><span class="line">          <span class="attribute">width</span>:<span class="number">70px</span>;</span><br><span class="line">          <span class="comment">/* 水平居中 */</span></span><br><span class="line">          <span class="attribute">left</span>:<span class="number">50%</span>;</span><br><span class="line">          <span class="attribute">margin-left</span>:-<span class="number">35px</span>;</span><br><span class="line">          <span class="comment">/* 白色半透明 */</span></span><br><span class="line">          <span class="attribute">background-color</span>: <span class="built_in">rgba</span>(<span class="number">255</span>,<span class="number">255</span>,<span class="number">255</span>,.<span class="number">4</span>);</span><br><span class="line">          <span class="comment">/* 圆角 */</span></span><br><span class="line">          <span class="attribute">border-radius</span>: <span class="number">7px</span>;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="selector-class">.nav</span> <span class="selector-tag">li</span>&#123;</span><br><span class="line">          <span class="comment">/* 让所有的小圆点浮动起来，都在一排 */</span></span><br><span class="line">          <span class="attribute">float</span>: left;</span><br><span class="line">          <span class="attribute">width</span>:<span class="number">8px</span>;</span><br><span class="line">          <span class="attribute">height</span>: <span class="number">8px</span>;</span><br><span class="line">          <span class="attribute">background-color</span>: <span class="number">#fff</span>;</span><br><span class="line">          <span class="comment">/* 变成圆形 */</span></span><br><span class="line">          <span class="attribute">border-radius</span>: <span class="number">50%</span>;</span><br><span class="line">          <span class="comment">/* 间隔开 :上下左右外边距都是3px*/</span></span><br><span class="line">          <span class="attribute">margin</span>:<span class="number">3px</span>;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="comment">/* 让选中的小圆点变成红色 */</span></span><br><span class="line">      <span class="selector-class">.nav</span> <span class="selector-class">.selected</span>&#123;</span><br><span class="line">          <span class="attribute">background-color</span>: red;</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="selector-tag">ul</span>&#123;</span><br><span class="line">          <span class="comment">/* 让宽度装得下4个li */</span></span><br><span class="line">          <span class="attribute">width</span>: <span class="number">400%</span></span><br><span class="line">      &#125;</span><br><span class="line">      <span class="selector-class">.pic</span> <span class="selector-tag">li</span>&#123;</span><br><span class="line">          <span class="comment">/* 让所有的li都在一行 */</span></span><br><span class="line">          <span class="attribute">float</span>: left;</span><br><span class="line">          <span class="attribute">height</span>: <span class="number">420px</span>;</span><br><span class="line">          <span class="attribute">width</span>: <span class="number">1090px</span>;</span><br><span class="line">      &#125;</span><br></pre></td></tr></table></figure>

<h2 id="核心（JS）"><a href="#核心（JS）" class="headerlink" title="核心（JS）"></a>核心（JS）</h2><h3 id="鼠标经过显示左右按钮"><a href="#鼠标经过显示左右按钮" class="headerlink" title="鼠标经过显示左右按钮"></a>鼠标经过显示左右按钮</h3><p>当鼠标经过轮播图时，左右按钮显示，并关闭自动播放的计时器。</p>
<p>当鼠标离开轮播图时，隐藏左右按钮，并开启自动播放的计时器。</p>
<h3 id="动态生成小圆圈"><a href="#动态生成小圆圈" class="headerlink" title="动态生成小圆圈"></a>动态生成小圆圈</h3><p>有几张图，就有几个小圆圈</p>
<p>即ul中多少个li，就在ol中生成相同个数的li</p>
<ol>
<li><p>统计ul中的li:ul.children.length，记作n(之后要用)</p>
</li>
<li><p>利用for循环，i从0到n-1，创建结点：createElement(“li”)，创建之后将li添加到ol中：ol.appendChild(li);</p>
</li>
</ol>
<h3 id="点击小圆圈的时候该小圆圈就会变成红色"><a href="#点击小圆圈的时候该小圆圈就会变成红色" class="headerlink" title="点击小圆圈的时候该小圆圈就会变成红色"></a>点击小圆圈的时候该小圆圈就会变成红色</h3><p>排他思想：干掉其他人，留下我自己</p>
<p>当点击当前小圆圈，先for循环将所有小圆圈的类名移出，然后给当前小圆圈绑定current的类名（用到了this指针）</p>
<p>放置位置：在前一步的动态插入li的时候就可以给每个li绑定一个单击响应函数</p>
<h3 id="点击小圆圈实现图片滑动效果"><a href="#点击小圆圈实现图片滑动效果" class="headerlink" title="点击小圆圈实现图片滑动效果"></a>点击小圆圈实现图片滑动效果</h3><p>要实现滑动，可以用动画函数，传入滑动的对象（ul）和滑动的距离。</p>
<p>放置位置：因为是在点击小圆圈后实现的，所以应该在小圆圈的单击相应函数中写</p>
<p>ul滚动距离：（-1）*小圆圈的索引号乘以图片的宽度</p>
<p>小圆圈的索引号：在动态添加li的时候就给li添加一个自定义属性index，<code>li.setAttribute(&quot;index&quot;, i);</code></p>
<p>因为只有绝对定位的对象才能用滑动动画函数，因此要给ul加绝对定位（移动的是ul，而不是li，因为如果是li在动，那剩下的li没办法安排)。</p>
<p>而既然给ul加了绝对定位，而在之前就已经给左右按钮加了绝对定位，要使左右按钮在ul上面，就要加大左右按钮的z-index，这里我设置成了z-index&#x3D;3</p>
<h3 id="点击左右按钮实现图片滑动效果"><a href="#点击左右按钮实现图片滑动效果" class="headerlink" title="点击左右按钮实现图片滑动效果"></a>点击左右按钮实现图片滑动效果</h3><p>声明一个变量num,点击右侧按钮，就自增一。</p>
<p>给左右按钮的点击也绑定监听的函数，放入动画函数，实现其滑动。ul的滑动距离就是num乘以图片的宽度</p>
<h3 id="无缝滚动"><a href="#无缝滚动" class="headerlink" title="无缝滚动"></a>无缝滚动</h3><p>把第一张图片复制一份放在最后一个li的后面（如果手动复制的话不方便后来添加图片，并且小圆点也会动态多生成一个），所以这里我们用<code>cloneNode()</code></p>
<p><code>cloneNode(),</code>加true是深克隆，会拷贝里面的子节点，如果是false就是浅克隆，不会拷贝里面的子节点</p>
<p>不管有没有到最后一张都执行的是：num++, animate滚动ul,距离是num乘以图片的宽度</p>
<p>如果到了最后一个，即n个(其实就是拷贝的第一个），则将ul不做动画的跳到最左侧，即left&#x3D;0,并把num改成0；</p>
<h3 id="点击右侧按钮时小圆点和右侧按钮一起变化"><a href="#点击右侧按钮时小圆点和右侧按钮一起变化" class="headerlink" title="点击右侧按钮时小圆点和右侧按钮一起变化"></a>点击右侧按钮时小圆点和右侧按钮一起变化</h3><p>再声明一个circle，每次点击右侧按钮自增1（不能用num,因为num因为图片克隆的原因会出现n的情况，而小圆点的索引只是[0,n-1]。</p>
<p>并且，当circle&#x3D;&#x3D;4的时候，应该将circle改成0</p>
<h3 id="统一变量"><a href="#统一变量" class="headerlink" title="统一变量"></a>统一变量</h3><p>circle:控制小圆点的current</p>
<p>num：控制左右按钮计数器</p>
<p>因为左右控制按钮时是通过num来控制的，但我们点击li来移动的时候并没有改变num，也没有改变current,则会导致在点击小圆点移动后再点击左右按钮时出现错误（因为左右按钮操控的时候是用num来控制是移动的距离，用circle来控制小圆点的current）。</p>
<p>所以需要在li的单击响应函数中，加入将this.index赋值给num和circle</p>
<h3 id="自动播放"><a href="#自动播放" class="headerlink" title="自动播放"></a>自动播放</h3><p>相当于点击右侧按钮，即使用right.click()【调用这个函数就相当于我们手动点击右侧按钮】</p>
<p>在全局中添加一个定时器，使得页面一加载就开始自动播放</p>
<p>鼠标放上的时候的监听函数增添：停止定时器timer</p>
<p>鼠标经过的时候的监听函数增添：开启定时器timer</p>
<h3 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br></pre></td><td class="code"><pre><span class="line">&lt;script&gt;</span><br><span class="line">       <span class="keyword">var</span> ad = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">&#x27;ad&#x27;</span>);</span><br><span class="line">       <span class="keyword">var</span> right = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">&#x27;right&#x27;</span>);</span><br><span class="line">       <span class="keyword">var</span> left = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">&#x27;left&#x27;</span>);</span><br><span class="line">       <span class="keyword">var</span> ul = <span class="variable language_">document</span>.<span class="title function_">querySelector</span>(<span class="string">&quot;ul&quot;</span>);</span><br><span class="line">       <span class="keyword">var</span> ol = <span class="variable language_">document</span>.<span class="title function_">querySelector</span>(<span class="string">&quot;ol&quot;</span>);</span><br><span class="line">       <span class="keyword">var</span> n = ul.<span class="property">children</span>.<span class="property">length</span>;     <span class="comment">//图片的个数</span></span><br><span class="line">       <span class="keyword">var</span> num = <span class="number">0</span>;                    <span class="comment">//左右按钮计数器</span></span><br><span class="line">       <span class="keyword">var</span> circle = <span class="number">0</span>;                   <span class="comment">//控制小圆圈的current</span></span><br><span class="line"></span><br><span class="line">       <span class="comment">//鼠标进入，出现左右符号，并停止自动播放，鼠标移出，左右符号消失,开启计时器</span></span><br><span class="line">       ad.<span class="title function_">addEventListener</span>(<span class="string">&quot;mouseenter&quot;</span>, <span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">           right.<span class="property">style</span>.<span class="property">display</span> = <span class="string">&quot;block&quot;</span>;</span><br><span class="line">           left.<span class="property">style</span>.<span class="property">display</span> = <span class="string">&quot;block&quot;</span>;</span><br><span class="line">           <span class="built_in">clearInterval</span>(timer);</span><br><span class="line">           timer = <span class="literal">null</span>;</span><br><span class="line">       &#125;);</span><br><span class="line">       ad.<span class="title function_">addEventListener</span>(<span class="string">&quot;mouseleave&quot;</span>, <span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">           right.<span class="property">style</span>.<span class="property">display</span> = <span class="string">&quot;none&quot;</span>;</span><br><span class="line">           left.<span class="property">style</span>.<span class="property">display</span> = <span class="string">&quot;none&quot;</span>;</span><br><span class="line">           timer = <span class="built_in">setInterval</span>(<span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">               right.<span class="title function_">click</span>();</span><br><span class="line">           &#125;, <span class="number">1700</span>);</span><br><span class="line"></span><br><span class="line">       &#125;);</span><br><span class="line">       <span class="comment">//根据图片的个数动态添加li</span></span><br><span class="line">       <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; n; i++) &#123;</span><br><span class="line">           <span class="keyword">var</span> li = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">&quot;li&quot;</span>);</span><br><span class="line">           ol.<span class="title function_">appendChild</span>(li);</span><br><span class="line">           <span class="comment">// 给小圆圈设置自定义属性添加索引号</span></span><br><span class="line">           li.<span class="title function_">setAttribute</span>(<span class="string">&quot;index&quot;</span>, i);</span><br><span class="line">           <span class="comment">//小圆圈的单击响应函数</span></span><br><span class="line">           li.<span class="title function_">addEventListener</span>(<span class="string">&quot;click&quot;</span>, <span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">               <span class="comment">//清空类名</span></span><br><span class="line">               <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; n; i++) &#123;</span><br><span class="line">                   ol.<span class="property">children</span>[i].<span class="property">className</span> = <span class="string">&quot;&quot;</span>;</span><br><span class="line">               &#125;</span><br><span class="line">               <span class="comment">//给当前li添加类名（巧妙运用this指针）</span></span><br><span class="line">               <span class="variable language_">this</span>.<span class="property">className</span> = <span class="string">&quot;current&quot;</span>;</span><br><span class="line">               <span class="comment">// 点击小圆圈移动ul</span></span><br><span class="line">               <span class="keyword">var</span> index = <span class="variable language_">this</span>.<span class="title function_">getAttribute</span>(<span class="string">&quot;index&quot;</span>);</span><br><span class="line">               num = index;</span><br><span class="line">               circle = index;</span><br><span class="line">               <span class="keyword">var</span> step = (-<span class="number">1</span>) * (index * <span class="number">1090</span>);</span><br><span class="line">               <span class="title function_">animate</span>(ul, step);</span><br><span class="line">           &#125;)</span><br><span class="line">       &#125;</span><br><span class="line">       <span class="comment">//初始：把ol里的第一个li的className设置为current</span></span><br><span class="line">       ol.<span class="property">children</span>[<span class="number">0</span>].<span class="property">className</span> = <span class="string">&quot;current&quot;</span>;</span><br><span class="line">       <span class="comment">//克隆第一个li放在最后</span></span><br><span class="line">       <span class="keyword">var</span> first = ul.<span class="property">children</span>[<span class="number">0</span>].<span class="title function_">cloneNode</span>(<span class="literal">true</span>);</span><br><span class="line">       ul.<span class="title function_">appendChild</span>(first);</span><br><span class="line">       <span class="comment">//右箭头点击</span></span><br><span class="line">       right.<span class="title function_">addEventListener</span>(<span class="string">&quot;click&quot;</span>, <span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">           <span class="keyword">if</span> (num == n) &#123;</span><br><span class="line">               ul.<span class="property">style</span>.<span class="property">left</span> = <span class="number">0</span>;</span><br><span class="line">               num = <span class="number">0</span>;</span><br><span class="line">           &#125;</span><br><span class="line">           num++;</span><br><span class="line">           <span class="comment">//小圆圈同步推进</span></span><br><span class="line">           circle++;</span><br><span class="line">           <span class="keyword">if</span> (circle == n) &#123;</span><br><span class="line">               circle = <span class="number">0</span>;</span><br><span class="line">           &#125;</span><br><span class="line">           <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; n; i++) &#123;</span><br><span class="line">               ol.<span class="property">children</span>[i].<span class="property">className</span> = <span class="string">&quot;&quot;</span>;</span><br><span class="line">           &#125;</span><br><span class="line">           ol.<span class="property">children</span>[circle].<span class="property">className</span> = <span class="string">&quot;current&quot;</span>;</span><br><span class="line"></span><br><span class="line">           <span class="title function_">animate</span>(ul, (-<span class="number">1</span>) * num * <span class="number">1090</span>);</span><br><span class="line">       &#125;)</span><br><span class="line">        <span class="comment">//左箭头点击</span></span><br><span class="line">       left.<span class="title function_">addEventListener</span>(<span class="string">&quot;click&quot;</span>, <span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">           <span class="keyword">if</span> (num == <span class="number">0</span>) &#123;</span><br><span class="line">               ul.<span class="property">style</span>.<span class="property">left</span> = (-<span class="number">1</span>) * <span class="number">1090</span> * n + <span class="string">&#x27;px&#x27;</span>;</span><br><span class="line">               num = n;</span><br><span class="line">           &#125;</span><br><span class="line">           num--;</span><br><span class="line">           <span class="comment">//小圆圈同步推进</span></span><br><span class="line">           circle--;</span><br><span class="line">           <span class="keyword">if</span> (circle &lt; <span class="number">0</span>) &#123;</span><br><span class="line">               circle = n - <span class="number">1</span>;</span><br><span class="line">           &#125;</span><br><span class="line">           <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; n; i++) &#123;</span><br><span class="line">               ol.<span class="property">children</span>[i].<span class="property">className</span> = <span class="string">&quot;&quot;</span>;</span><br><span class="line">           &#125;</span><br><span class="line">           ol.<span class="property">children</span>[circle].<span class="property">className</span> = <span class="string">&quot;current&quot;</span>;</span><br><span class="line"></span><br><span class="line">           <span class="title function_">animate</span>(ul, (-<span class="number">1</span>) * num * <span class="number">1090</span>);</span><br><span class="line">       &#125;)</span><br><span class="line"></span><br><span class="line">       <span class="comment">// 自动播放图片，相当于点击右侧按钮</span></span><br><span class="line">       <span class="keyword">var</span> timer = <span class="built_in">setInterval</span>(<span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">           right.<span class="title function_">click</span>();</span><br><span class="line">       &#125;, <span class="number">2000</span>);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">       <span class="comment">//滑动动画效果</span></span><br><span class="line">       <span class="keyword">function</span> <span class="title function_">animate</span>(<span class="params">obj, target</span>) &#123;</span><br><span class="line">           <span class="comment">//清除之前的定时器，防止多次点击</span></span><br><span class="line">           <span class="built_in">clearInterval</span>(obj.<span class="property">timer</span>);</span><br><span class="line">           obj.<span class="property">timer</span> = <span class="built_in">setInterval</span>(<span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">               <span class="keyword">var</span> step = (target - obj.<span class="property">offsetLeft</span>) / <span class="number">10</span>;</span><br><span class="line">               step = step &gt; <span class="number">0</span> ? <span class="title class_">Math</span>.<span class="title function_">ceil</span>(step) : <span class="title class_">Math</span>.<span class="title function_">floor</span>(step);</span><br><span class="line">               <span class="keyword">if</span> (obj.<span class="property">offsetLeft</span> == target) &#123;</span><br><span class="line">                   <span class="built_in">clearInterval</span>(obj.<span class="property">timer</span>);</span><br><span class="line">               &#125;</span><br><span class="line">               obj.<span class="property">style</span>.<span class="property">left</span> = obj.<span class="property">offsetLeft</span> + step + <span class="string">&#x27;px&#x27;</span>;</span><br><span class="line">           &#125;, <span class="number">15</span>);</span><br><span class="line">       &#125;</span><br><span class="line">   &lt;/script&gt;</span><br></pre></td></tr></table></figure>


    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2022/04/02/CSS/" rel="prev" title="CSS自学笔记">
      <i class="fa fa-chevron-left"></i> CSS自学笔记
    </a></div>
      <div class="post-nav-item">
    <a href="/2022/04/03/%E9%93%BE%E8%A1%A8%E5%88%B7%E9%A2%98/" rel="next" title="链表刷题">
      链表刷题 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%BD%91%E6%98%93%E4%BA%91%E9%9F%B3%E4%B9%90%E7%9A%84%E8%BD%AE%E6%92%AD%E5%9B%BE%E8%87%AA%E5%88%B6"><span class="nav-number">1.</span> <span class="nav-text">网易云音乐的轮播图自制~</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%A1%B5%E9%9D%A2%E5%B8%83%E5%B1%80%EF%BC%88HTML%EF%BC%89"><span class="nav-number">2.</span> <span class="nav-text">页面布局（HTML）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%A0%B7%E5%BC%8F-CSS"><span class="nav-number">3.</span> <span class="nav-text">样式(CSS)</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%A0%B8%E5%BF%83%EF%BC%88JS%EF%BC%89"><span class="nav-number">4.</span> <span class="nav-text">核心（JS）</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%BC%A0%E6%A0%87%E7%BB%8F%E8%BF%87%E6%98%BE%E7%A4%BA%E5%B7%A6%E5%8F%B3%E6%8C%89%E9%92%AE"><span class="nav-number">4.1.</span> <span class="nav-text">鼠标经过显示左右按钮</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8A%A8%E6%80%81%E7%94%9F%E6%88%90%E5%B0%8F%E5%9C%86%E5%9C%88"><span class="nav-number">4.2.</span> <span class="nav-text">动态生成小圆圈</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%82%B9%E5%87%BB%E5%B0%8F%E5%9C%86%E5%9C%88%E7%9A%84%E6%97%B6%E5%80%99%E8%AF%A5%E5%B0%8F%E5%9C%86%E5%9C%88%E5%B0%B1%E4%BC%9A%E5%8F%98%E6%88%90%E7%BA%A2%E8%89%B2"><span class="nav-number">4.3.</span> <span class="nav-text">点击小圆圈的时候该小圆圈就会变成红色</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%82%B9%E5%87%BB%E5%B0%8F%E5%9C%86%E5%9C%88%E5%AE%9E%E7%8E%B0%E5%9B%BE%E7%89%87%E6%BB%91%E5%8A%A8%E6%95%88%E6%9E%9C"><span class="nav-number">4.4.</span> <span class="nav-text">点击小圆圈实现图片滑动效果</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%82%B9%E5%87%BB%E5%B7%A6%E5%8F%B3%E6%8C%89%E9%92%AE%E5%AE%9E%E7%8E%B0%E5%9B%BE%E7%89%87%E6%BB%91%E5%8A%A8%E6%95%88%E6%9E%9C"><span class="nav-number">4.5.</span> <span class="nav-text">点击左右按钮实现图片滑动效果</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%97%A0%E7%BC%9D%E6%BB%9A%E5%8A%A8"><span class="nav-number">4.6.</span> <span class="nav-text">无缝滚动</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%82%B9%E5%87%BB%E5%8F%B3%E4%BE%A7%E6%8C%89%E9%92%AE%E6%97%B6%E5%B0%8F%E5%9C%86%E7%82%B9%E5%92%8C%E5%8F%B3%E4%BE%A7%E6%8C%89%E9%92%AE%E4%B8%80%E8%B5%B7%E5%8F%98%E5%8C%96"><span class="nav-number">4.7.</span> <span class="nav-text">点击右侧按钮时小圆点和右侧按钮一起变化</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BB%9F%E4%B8%80%E5%8F%98%E9%87%8F"><span class="nav-number">4.8.</span> <span class="nav-text">统一变量</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%87%AA%E5%8A%A8%E6%92%AD%E6%94%BE"><span class="nav-number">4.9.</span> <span class="nav-text">自动播放</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%A3%E7%A0%81"><span class="nav-number">4.10.</span> <span class="nav-text">代码</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="芷若"
      src="/images/touxiang.jpg">
  <p class="site-author-name" itemprop="name">芷若</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">19</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">5</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/zhiruo" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;zhiruo" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">陕ICP备2022001874号 </a>
      <img src="http://www.beian.gov.cn/portal/download" style="display: inline-block;">
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="芷若"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">芷若</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">105k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">1:35</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="//cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js"></script>
<script src="//cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js"></script>
<script src="/js/algolia-search.js"></script>














  

  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/assets/koharu.model.json"},"display":{"position":"right","width":145,"height":315},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":0.7,"opacityOnHover":0.8},"log":false});</script></body>
</html>
